#include <iostream>
using namespace std;

int main()
{
    long long n, m, a, b;
    cin >> n >> m >> a >> b;
    long long x = min(n / 2, m);
    long long ret = 0;
    //cout<<x<<endl;
    for (long long i = 0; i <= x; i++)
    {
        long long y = min(n - 2 * i, (m - i) / 2);
        ret = max(ret, a * i + b * y);
    }

    cout << ret << endl;

    return 0;
}